﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Fundamental.OperatorOverload
{
    internal class Overload
    {
        public int X;
        public int Y;

        public Overload(int x, int y)
        {
            X = x;
            Y = y;
        }

        public override string ToString()
        {
            return string.Format("X={0}, Y={1}",X,Y);
        }

        public static Overload operator +(Overload a, Overload b)
        {
            return new Overload(a.X + b.X, a.Y + b.Y);
        }

        public static implicit operator Overload(string str)
        {
            string[] stringArray = str.Split(new char[]{','});

            if (stringArray.Length < 2) throw new InvalidOperationException();

            return new Overload(Convert.ToInt32(stringArray[0]), Convert.ToInt32(stringArray[1]));

        }
    }
}
